# Create your views here.
from django.core.context_processors import csrf
from django.core.mail import send_mail
from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
from solar.careers.form import CareerRegistrationForm
from solar.careers.models import CareerRegistration

def careers(request):
    c = {}
    c.update(csrf(request))
    if request.method == 'POST':   
        form = CareerRegistrationForm(request.POST)
        
        if form.is_valid():
            cd = form.cleaned_data
            reg = CareerRegistration.objects.create(name=cd['name'], 
                                              gender=cd['gender'],
                                              phone=cd['phone'],
                                              email=cd['email'],
                                              org=cd['org'],
                                              department=cd['department'],
                                              status=cd['status'],
                                              )
            return redirect('/careersreg/')
    else:
        form = CareerRegistrationForm()
    c.update({'form':form})
    c.update({'post_data':request.POST})   
    c.update({'careersstatus':'active'}) 
    
    return render_to_response('careers.html', c)
def finishRegistration(request):
    return render_to_response('careersreg.html')
